<template>
	<view class="share w100 vh100">
		<!-- <view class="fixed" style="bottom: 50vh;left: 51.5%;transform: translateX(-50%);border: 20rpx solid #fff; font-size: 0;">
			<!-- <qrcode ref="qrcode" :val="share_url" :size="size" :background="background" :foreground="foreground" :pdground="pdground"
			 :icon="icon" :iconSize="iconsize" :lv="lv" :onval="onval" :loadMake="loadMake" @result="qrR" /> -->
			<!-- <u-image width="100%" height="300rpx" :src="down_url"></u-image> -->
		<!-- </view> -->
		<view class="fixed" style="bottom: 45vh;left: 51.5%;transform: translateX(-50%);border: 20rpx solid #fff; font-size: 0;">
			<u-image width="500rpx" height="500rpx" shape="square" :src="down_url"></u-image>
		</view>
		<view class="fixed-bottom flex plr-30 pb-60">
			<!-- <view @click="copy" class="yellow radius-10 text-center ptb-20 u-flex-1 mr-30" style="background: #FFF2EA;">复制推广链接</view> -->
			<view @click="back" class="yellow radius-10 text-center ptb-20 u-flex-1 mr-30" style="background: #FFF2EA;">返回上一页</view>
			<!-- <view @click="save" class="u-flex-1 bg-white yellow ptb-20 radius-10 text-center">保存图片</view> -->
		</view>
	</view>
</template>

<script>
	import qrcode from '../../components/tki-qrcode/tki-qrcode.vue'
	export default {
		data() {
			return {
				url: '',
				share_url: '',
				down_url: '',

				//二维码
				val: '', //二维码内容
				size: 230,
				background: '#ffffff',
				foreground: '#000000',
				pdground: '#000000',
				icon: '',
				iconsize: 40,
				lv: 3,
				onval: true,
				loadMake: true,
				src: '',
			};
		},
		components: {
			qrcode
		},
		onLoad() {
			this.$http('/api/wechat/shareqrcode').then(data => {
				this.url = data.url;
				this.share_url = data.url;
				this.down_url = data.down_url;
			});
		},
		methods: {
			creatQrcode() {
				this.$refs.qrcode._makeCode()
			},
			qrR(res) {
				console.log(res, 'res')
				this.src = res
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			copy() {
				uni.setClipboardData({
					data: this.share_url,
					success: function() {
						uni.showToast({
							title: '复制成功'
						})
					}
				});
			},
			save() {
				uni.downloadFile({
					url: this.url, //仅为示例，并非真实的资源
					success: (res) => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: '保存成功'
									})
								}
							});
						}
					}
				});


			}
		}
	}
</script>

<style lang="scss">
	.share {
		// background: url('') no-repeat top center;
		background-size: 100% 100%;
	}
</style>
